Added method XendDomain.privilegedDomain and use that inside DevController to
authoremellor@ewan <emellor@ewan>
Mon, 3 Oct 2005 23:21:49 +0000 (00:21 +0100)
committeremellor@ewan <emellor@ewan>
Mon, 3 Oct 2005 23:21:49 +0000 (00:21 +0100)
avoid hard-coding the domain ID 0.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/server/DevController.py

index f21d08edbbcfb277a213975fe32759e77edfc173..81302ad03190298fe27c4aac10616abf7f3de20d 100644 (file)
@@ -284,6 +284,11 @@ class XendDomain:
                 pass
         return dominfo
 
+
+    def privilegedDomain(self):
+        return self.domains[PRIV_DOMAIN]
+
     def domain_unpause(self, id):
         """Unpause domain execution.
 
index 0ede664ba09d824ad30b160da9b903b9d3fa2fbc..c9fc72ebaaeca0c1ba52db5d2bc347c837fb3450 100644 (file)
@@ -189,8 +189,17 @@ class DevController:
         """
 
         import xen.xend.XendDomain
-        backdom = xen.xend.XendDomain.instance().domain_lookup_by_name(
-            sxp.child_value(config, 'backend', '0'))
+        xd = xen.xend.XendDomain.instance()
+
+        backdom_name = sxp.child_value(config, 'backend')
+        if backdom_name:
+            backdom = xd.domain_lookup_by_name(backdom_name)
+        else:
+            backdom = xd.privilegedDomain()
+
+        if not backdom:
+            raise VmError("Cannot configure device for unknown backend %s" %
+                          backdom_name)
 
         frontpath = self.frontendPath(devid)
         backpath  = self.backendPath(backdom, devid)